﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HotelSoft.HotelManagement_BUS;
using System.Collections;
using HotelSoft.HotelManagement_DTO;

namespace HotelSoft.HotelManagement_GUI
{
    public partial class frmBaocao_NGAY : Form
    {
        // Define the CS_DROPSHADOW constant
        private const int CS_DROPSHADOW = 0x00020000;

        // Override the CreateParams property
        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams cp = base.CreateParams;
                cp.ClassStyle |= CS_DROPSHADOW;
                return cp;
            }
        }
        Double temp = 1;
        THONGKE_NGAYDTO dtoTK;
        BaoCaoDoanhThuTheoLoaiBUS busTK = new BaoCaoDoanhThuTheoLoaiBUS();
        public frmBaocao_NGAY()
        {
            InitializeComponent();
        }

        private void frmBaocao_NGAY_Load(object sender, EventArgs e)
        {
            timer1.Enabled = true;
            lblTongsoDT.Text = "0";
            lblTongsoSLT.Text = "0";
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Opacity = this.Opacity + 0.1;
            if (this.Opacity == temp)
            {
                timer1.Enabled = false;
            }
        }


        public void LoadListViewMD(string Date)
        {
            dtoTK = new THONGKE_NGAYDTO();
            dtoTK.DATE = Date;
            DataTable tbl = new DataTable();
            tbl = busTK.BCMD_NGAY(dtoTK);
            dgMD.DataSource = tbl.DefaultView;
        }

        public void LoadListViewDT(string Date)
        {
            dtoTK = new THONGKE_NGAYDTO();
            dtoTK.DATE = Date;
            DataTable tbl = new DataTable();
            tbl = busTK.BCDT_NGAY(dtoTK);
            dgDT.DataSource = tbl.DefaultView;
        }

        private void Btn_ThongKe_Click(object sender, EventArgs e)
        {
            if (dtinput.Text == "")
            {
                MessageBox.Show("Xin hãy chọn ngày cần thống kê!","Báo cáo thống kê - Ngày");
                dtinput.Focus();
                return;
            }
            if (tabControl1.SelectedTabIndex == 0)
            {
                lblNgayDT.Text = dtinput.Text;
                LoadListViewDT(dtinput.Text);
                THONGKE_NGAYDTO dto=new THONGKE_NGAYDTO();
                dto.DATE=dtinput.Text;
                DataTable tbl = new DataTable();
                tbl = busTK.BCDT_LOAIPHONG_Tong(dto);
                lblTongsoDT.Text = tbl.Rows[0].ItemArray[0].ToString();
            }
            else
            {
                lblNgayMD.Text = dtinput.Text;
                LoadListViewMD(dtinput.Text);
                THONGKE_NGAYDTO dto = new THONGKE_NGAYDTO();
                dto.DATE = dtinput.Text;
                DataTable tbl = new DataTable();
                tbl = busTK.BCMD_PHONG_Tong(dto);
                lblTongsoSLT.Text = tbl.Rows[0].ItemArray[0].ToString();
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnInDS_Click(object sender, EventArgs e)
        {
            if (tabControl1.SelectedTabIndex == 0)
            {
                frmReport_BaoCaoDoanhThu frm = new frmReport_BaoCaoDoanhThu();
                frm.LOAI = 0;
                frm.NGAY = dtinput.Text;
                frm.ShowDialog();
            }
            else
            {
                frmReport_BaoCaomatdo frm = new frmReport_BaoCaomatdo();
                frm.LOAI = 0;
                frm.NGAY = dtinput.Text;
                frm.ShowDialog();
            }
        }
    }
}
